package com.iamback.dy.examine.controller.admin.system;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.iamback.dy.entity.UserAssign;
import com.iamback.dy.examine.common.JsonResult;
import com.iamback.dy.examine.common.Page;
import com.iamback.dy.examine.service.IUserService;
import com.iamback.dy.examine.vo.UserAssignView;

@Controller
@RequestMapping("/admin/user")
public class UserAssignController {

	@Autowired
	private IUserService userService;
	
	@RequestMapping(value = "/assign")
	public String showUserAssign(){
		return "admin/assign/assignindex";
	}
	
	@RequestMapping(value = "/assign/list")
	@ResponseBody
	public Page<UserAssignView> getUserAssignPage(Integer pageNumber,Integer pageSize){
		Page<UserAssignView> page =userService.getUserAssignPage(pageNumber, pageSize);
		return page;
	}
	
	@RequestMapping(value = "/assign/update")
	@ResponseBody
	public JsonResult updateUserAssign(@RequestBody UserAssignView userAssignView){
		UserAssign userAssign =new UserAssign();
		if(userAssignView.getAssignId() !=null){
			userAssign.setId(userAssignView.getAssignId());
		}
		userAssign.setUserId(userAssignView.getUserId());
		userAssign.setAssignType(userAssignView.getAssignType());
		userService.updateUserAssign(userAssign);
		return JsonResult.success();
	}
	
}
